class Solution
{
public:
    vector<string> findWords(vector<string> &words)
    {
        constexpr char line1[] = "qwertyuiopQWERTYUIOP";
        constexpr char line2[] = "asdfghjklASDFGHJKL";
        constexpr char line3[] = "zxcvbnmZXCVBNM";
        int charLine[128] = {0};
        for (char c : line1)
        {
            charLine[c] = 1;
        }
        for (char c : line2)
        {
            charLine[c] = 2;
        }
        for (char c : line2)
        {
            charLine[c] = 2;
        }

        vector<string> result;
        for (auto &word : words)
        {
            int line = charLine[word[0]];
            bool isSameLine = true;
            for (char c : word)
            {
                if (line != charLine[c])
                {
                    isSameLine = false;
                    break;
                }
            }
            if (isSameLine)
            {
                result.push_back(word);
            }
        }
        return result;
    }
};